package pl.iachoo.ctl.tabory.dao.data.sl;

public enum UserRoleSL {

	ADMINISTRATOR(0, "admin"), REGULAR(1, "regular"), REPORTER(2, "reporter");

	private UserRoleSL(Integer id, String name) {
		this.id = id;
		this.name = name;
	}

	private Integer id;
	private String name;

	public Integer getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public static int getRoleId(String roleName) {
		for (UserRoleSL userRole : UserRoleSL.values()) {
			if (userRole.getName().equals(roleName)) {
				return userRole.getId();
			}
		}
		return -1;
	}

	public static UserRoleSL getUserRole(int id) {
		for (UserRoleSL userRole : UserRoleSL.values()) {
			if (userRole.getId().equals(id)) {
				return userRole;
			}
		}
		return null;
	}

}
